<?php
namespace lib\YanPHP;


class controll{
    
    public $assign = [];

    public function assign($name, $value){
        $this->assign[$name] = $value; 
    }

    public function display($name = ''){
        $smarty = new \Smarty;
        //$smarty->left_delimiter = "{#";
        //$smarty->right_delimiter = "#}";
        $smarty->setTemplateDir(ROOT_PATH . '/view/'); //设置模板目录
        $smarty->setCompileDir(ROOT_PATH . '/runtime/templates_c/');
        $smarty->setConfigDir(ROOT_PATH . '/public/smarty_configs/');
        $smarty->setCacheDir(ROOT_PATH . '/runtime/smarty_cache/');
        $smarty->registerPlugin("function","url","smarty_url");
        //$smarty->force_compile = true;
        if (APP_DEBUG) {
            //$smarty->debugging      = true;
            $smarty->caching        = false;
            $smarty->cache_lifetime = 0;
        } else {
            //$smarty->debugging      = false;
            $smarty->caching        = true;
            $smarty->cache_lifetime = 120;
        }
        foreach ($this->assign as $key => $value) {
            $smarty->assign($key, $value);
        }
        
        $smarty->display($name . '.html');
    }
}
